/**
 * 
 */
package org.going.factory;

import java.util.HashMap;
import java.util.Map;

import org.going.invoker.ArrayValueGeneratorImpl;
import org.going.invoker.ParamValueGenerator;
import org.going.invoker.PojoParamValueGeneratorImpl;
import org.going.invoker.PrimitiveClassValueGeneratorImpl;
import org.going.utils.ClassUtils;

/**
 * @author ferendo.huang@gmail.com
 * 
 */
public class ParamValueGeneratorFactory
{
	private final static Map<String, ParamValueGenerator> map = new HashMap<String, ParamValueGenerator>();
	private final static String KEY_GENERIC = "generic";
	private final static String KEY_ARRAY = "array";
	private final static String KEY_POJO = "pojo";

	static
	{
		map.put(KEY_GENERIC, new PrimitiveClassValueGeneratorImpl());
		map.put(KEY_POJO, new PojoParamValueGeneratorImpl());
		map.put(KEY_ARRAY, new ArrayValueGeneratorImpl());
	}

	public static ParamValueGenerator getValueGenerator(Class<?> clazz)
	{
		if (ClassUtils.isPrimitiveClass(clazz))
		{
			return map.get(KEY_GENERIC);
		}
		if (ClassUtils.isArray(clazz))
		{
			return map.get(KEY_ARRAY);
		}
		return map.get(KEY_POJO);
	}
}
